﻿<%@ Page Title="Article Administration" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="ArticleAdmin.aspx.vb" Inherits="bookmeetprototype.ArticleAdmin" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<ul class="breadcrumb">
    <li><a id="A1" runat="server" href="~/Default.aspx">Home</a> <span class="divider">/</span></li>
    <li><a id="A2" runat="server" href="~/Account/editprofile.aspx">User</a> <span class="divider">/</span></li>
    <li class="active">Article Administration</li>
    </ul>
    <asp:PlaceHolder ID="articleWriter" runat="server"><h3>Hello, 
    <asp:LoginName ID="LoginName1" runat="server" /></h3></asp:PlaceHolder>
   
<h2>Why Not Write An Article For Us?</h2>
<p class="lead">As the privileged user that you are, you are entitled to write literary articles that will be posted on our Discuss main page. Please use the box below to write your articles. Articles may be written in plain text, or in HTML, and you can link media such as audio and pictures as much as you want!</p>
   
        <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </ajaxToolkit:ToolkitScriptManager>
       <h3>Article Details:</h3>
            <p>
                <asp:Label ID="Label1" runat="server" Text="Title"></asp:Label>&nbsp;
                <asp:TextBox ID="ArticleTitle" runat="server" Height="29px" Width="410px"></asp:TextBox></p>
                <p>
                    <asp:Label ID="Label2" runat="server" Text="Category"></asp:Label>&nbsp;<asp:DropDownList
                        ID="CategoryDropDown" runat="server">
                        <asp:ListItem>Book Review</asp:ListItem>
                        <asp:ListItem>Discussion</asp:ListItem>
                        <asp:ListItem>News</asp:ListItem>
                    </asp:DropDownList>
                </p>
        <p>
                    <asp:Button ID="Button2" runat="server" BackColor="White" Font-Names="Tahoma" 
                        Text="Clear" />
        </p>
        <asp:TextBox ID="TextBox1" runat="server" Height="330px" Width="744px"></asp:TextBox>
    <p>
        <ajaxToolkit:HtmlEditorExtender ID="TextBox1_HtmlEditorExtender" OnImageUploadComplete="HTMLEditorExtender_ImageUploadComplete" DisplaySourceTab="true" runat="server" 
            Enabled="True" TargetControlID="TextBox1" EnableSanitization="false" >
               <Toolbar> 
                <ajaxToolkit:Bold />
                <ajaxToolkit:Italic />
                <ajaxToolkit:Underline />
                <ajaxToolkit:JustifyLeft />
                <ajaxToolkit:JustifyCenter />
                <ajaxToolkit:JustifyRight />
                <ajaxToolkit:JustifyFull />
                <ajaxToolkit:InsertOrderedList />
                <ajaxToolkit:InsertUnorderedList />
                <ajaxToolkit:CreateLink />
                <ajaxToolkit:UnLink />
                <ajaxToolkit:ForeColorSelector />
                <ajaxToolkit:FontNameSelector />
                <ajaxToolkit:FontSizeSelector />
                <ajaxToolkit:InsertImage />
            </Toolbar>
        </ajaxToolkit:HtmlEditorExtender>
    </p>
        <p>
        <asp:Button ID="Button1" runat="server" Text="Publish" />
                </p>
        <p>
            <asp:Label ID="ErrorMessage" runat="server" ForeColor="Red"></asp:Label>
                </p>
        <p>
            &nbsp;</p>
        
            <h2>Your Previous Articles:</h2>
        <asp:ListView ID="ListView1" runat="server" DataKeyNames="ID" 
            DataSourceID="SqlDataSource1">
            <AlternatingItemTemplate>
                <li style="">
                    Title:
                    <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
                    <br />
                    Category:
                    <asp:Label ID="CategoryLabel" runat="server" Text='<%# Eval("Category") %>' />
                    <br />
                    Date Posted:
                    <asp:Label ID="DateOfPostLabel" runat="server" 
                        Text='<%# Eval("DateOfPost") %>' />
                    <br />
                    <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                    <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                        Text="Delete" />
                </li>
            </AlternatingItemTemplate>
            <EditItemTemplate>
                <li style="">
                    Title:
                    <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>' />
                    <br />
                    Category:
                    <asp:TextBox ID="CategoryTextBox" runat="server" 
                        Text='<%# Bind("Category") %>' />
                    <br />
                    Date Posted:
                    <asp:TextBox ID="DateOfPostTextBox" runat="server" 
                        Text='<%# Bind("DateOfPost") %>' />
                    <br />
                    <asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                        Text="Update" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                        Text="Cancel" />
                </li>
            </EditItemTemplate>
            <EmptyDataTemplate>
                You haven't published any articles yet :(
            </EmptyDataTemplate>
            <InsertItemTemplate>
                <li style="">Title:
                    <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>' />
                    <br />Category:
                    <asp:TextBox ID="CategoryTextBox" runat="server" 
                        Text='<%# Bind("Category") %>' />
                    <br />UserName:
                    <asp:TextBox ID="UserNameTextBox" runat="server" 
                        Text='<%# Bind("UserName") %>' />
                    <br />DateOfPost:
                    <asp:TextBox ID="DateOfPostTextBox" runat="server" 
                        Text='<%# Bind("DateOfPost") %>' />
                    <br />HTMLPost:
                    <asp:TextBox ID="HTMLPostTextBox" runat="server" 
                        Text='<%# Bind("HTMLPost") %>' />
                    <br />
                    <asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
                        Text="Insert" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                        Text="Clear" />
                </li>
            </InsertItemTemplate>
            <ItemSeparatorTemplate>
<br />
            </ItemSeparatorTemplate>
            <ItemTemplate>
                <li style="">
                    Title:
                    <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
                    <br />
                    Category:
                    <asp:Label ID="CategoryLabel" runat="server" Text='<%# Eval("Category") %>' />
                    <br />
                    Date Posted:
                    <asp:Label ID="DateOfPostLabel" runat="server" 
                        Text='<%# Eval("DateOfPost") %>' />
                    <br />
                    <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                    <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                        Text="Delete" />
                </li>
            </ItemTemplate>
            <LayoutTemplate>
                <ul ID="itemPlaceholderContainer" runat="server" style="">
                    <li runat="server" id="itemPlaceholder" />
                </ul>
                <div style="">
                    <asp:DataPager ID="DataPager1" runat="server">
                        <Fields>
                            <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                ShowNextPageButton="False" ShowPreviousPageButton="False" />
                            <asp:NumericPagerField />
                            <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
                                ShowNextPageButton="False" ShowPreviousPageButton="False" />
                        </Fields>
                    </asp:DataPager>
                </div>
            </LayoutTemplate>
            <SelectedItemTemplate>
               <li style="">
                    Title:
                    <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
                    <br />
                    Category:
                    <asp:Label ID="CategoryLabel" runat="server" Text='<%# Eval("Category") %>' />
                    <br />
                    Date Posted:
                    <asp:Label ID="DateOfPostLabel" runat="server" 
                        Text='<%# Eval("DateOfPost") %>' />
                    <br />
                    <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                    <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                        Text="Delete" />
                </li>
                </li>
            </SelectedItemTemplate>
        </asp:ListView>
        <p>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:BookMeetConnString %>" 
                DeleteCommand="DELETE FROM [UserArticles] WHERE [ID] = ?" 
                InsertCommand="INSERT INTO [UserArticles] ([ID], [Title], [Category], [UserName], [DateOfPost], [HTMLPost]) VALUES (?, ?, ?, ?, ?, ?)" 
                ProviderName="<%$ ConnectionStrings:BookMeetConnString.ProviderName %>" 
                SelectCommand="SELECT * FROM [UserArticles] WHERE ([UserName] = ?)" 
                UpdateCommand="UPDATE [UserArticles] SET [Title] = ?, [Category] = ?, [UserName] = ?, [DateOfPost] = ?, [HTMLPost] = ? WHERE [ID] = ?">
                <DeleteParameters>
                    <asp:Parameter Name="ID" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="ID" Type="Int32" />
                    <asp:Parameter Name="Title" Type="String" />
                    <asp:Parameter Name="Category" Type="String" />
                    <asp:Parameter Name="UserName" Type="String" />
                    <asp:Parameter Name="DateOfPost" Type="DateTime" />
                    <asp:Parameter Name="HTMLPost" Type="String" />
                </InsertParameters>
                <SelectParameters>
                    <asp:SessionParameter Name="UserName" SessionField="userName" Type="String" />
                </SelectParameters>
                <UpdateParameters>
                    <asp:Parameter Name="Title" Type="String" />
                    <asp:Parameter Name="Category" Type="String" />
                    <asp:Parameter Name="UserName" Type="String" />
                    <asp:Parameter Name="DateOfPost" Type="DateTime" />
                    <asp:Parameter Name="HTMLPost" Type="String" />
                    <asp:Parameter Name="ID" Type="Int32" />
                </UpdateParameters>
            </asp:SqlDataSource>
        </p>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="SidebarContent" runat="server">
    <h4>Famous opening lines:</h4>
 
    <asp:Repeater id="quoteCascade" runat="server">
    <ItemTemplate>
    <blockquote>
        "<%#Container.DataItem("Quote")%>"
    <small>
        <%#Container.DataItem("SourceName")%><cite title="Source Title">
            <%#Container.DataItem("SourceTitle")%></cite></small>
    </blockquote>
    </ItemTemplate>
    </asp:Repeater>
    <script type="javascript" src="~/js/bootstrap-dropdown.js"></script>
    <script type="text/javascript">
        jQuery(function ($) {
            alert("Starting Dropdown");
            $('.dropdown-toggle').dropdown();
        });
</script>
    </asp:Content>
   